<template>
  <div>
    <MyHeader
      :background="'blue'"
      title="TabBar案例"
    ></MyHeader>

    <!-- 切换主页 -->
    <div class="main">
      <component :is='comName'></component>
    </div>


    <!-- 页面底部 -->
    <MyTabBar 
    :list='tabList'
    @changeCom="changeComFn"
    ></MyTabBar>
  </div>
</template>

<script>
// 引入各个组件
import MyHeader from "./components/MyHeader";
import MyTabBar from './components/MyTabBar.vue'
import MyGoodsList from './views/MyGoodsList.vue'
import MyGoodsSearch from './views/MyGoodsSearch.vue'
import MyUserInfo from './views/MyUserInfo.vue'

export default {
  // 注册各个组件
  components: {
    MyTabBar,
    MyHeader,
    MyGoodsList,
    MyGoodsSearch,
    MyUserInfo
  },
  data() {
    return {
      comName:'MyGoodsList',//默认显示的主页
      tabList: [
        {
          iconText: "icon-shangpinliebiao",
          text: "商品列表",
          componentName: "MyGoodsList",
        },
        {
          iconText: "icon-sousuo",
          text: "商品搜索",
          componentName: "MyGoodsSearch",
        },
        {
          iconText: "icon-user",
          text: "我的信息",
          componentName: "MyUserInfo",
        },
      ],
    };
  },
  methods: {
    changeComFn(comName){
      this.comName = comName; //传过来的组件名赋值给comName
    }
  }
}
</script>

<style scoped>
.main{
  padding-top: 45px;
  padding-bottom: 51px;
}
</style>